package com.yf1706.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.yf1706.bean.Dep;
import com.yf1706.bean.QuestionBank;
import com.yf1706.dao.jpa.IDepJDAO;

@Service
@Transactional(rollbackFor=Exception.class)
public class DepService {
	@Autowired
	private IDepJDAO djdao;
	
	public List<Dep> findAllDep(){
		return djdao.findAll();
	}
	
	public Dep findByDepId(int id) {
		return djdao.findByDepId(id);
	}
	
	//增加题库的同时给部门绑定题库id
	public void addQuestionbankId(Dep dep,QuestionBank qb) {
		dep.setQb(qb);
		djdao.save(dep);
	}
	
	public Dep findByDepName(String depName) {
		return djdao.findByDepName(depName);
	}
}
